$(function(){
	
	$('#nav-list').find('a').on('click',function(){
		$('#nav-list').find('a').css("color","#fff")
		$(this).css("color","#1587ea")
		
	});
	
	var timer = null;
		$('#banner-list').hover(function() {
			//console.log(this)

			clearInterval(timer);
		}, function() {

			autoPlay();
		})
		var lis = $('.img')
		var index = 0;
		$('.img').css("opacity","0")
		lis[index].style.opacity = 1;
		
		
		var a = $('#pagebox li')
		for(var i = 0; i < a.length; i++) {
			a[i].index = i;
			a[i].onclick = function() {
				//console.log(this.index)
				pageShow(this.index);
				lis.eq(this.index).stop().animate({
					opacity: 1
				}).siblings().stop().animate({
					opacity: 0
				})
				index = this.index
			}
		}
		pageShow(index)
		autoPlay();
		function move() {
			if(index < 0) {
				index = lis.size() - 1;
			}
			if(index >= lis.size()) {
				index = 0;
			}
			pageShow(index);
			lis.eq(index).stop().animate({
				opacity: 1
			},'slow').siblings().stop().animate({
				opacity: 0
			},'slow',"linear")

		}

		function pageShow(index) {
			//console.log(this);
			//console.log($('.partr a'))
			$('#pagebox li').removeClass('active').eq(index).addClass('active')
		}
		

		function autoPlay() {
			timer = setInterval(function() {
				index++;
				move();

				//模拟 触发事件
				//					rightBtn.trigger('click')

			}, 3000)
		}
		
		
		
		for(var i=0;i<$('.goods-list li').length;i++){
			//console.log(i)
			if(i % 4 == 0){
				$('.goods-list li').eq(i).css("margin-left",0)
			}
		}
		
})
	
